/*
 * Container.hpp
 *
 *  Created on: Oct 8, 2013
 *      Author: z1083248
 */

#ifndef CONTAINER_HPP_
#define CONTAINER_HPP_

#include <boost/any.hpp>
#include "Data.hpp"
#include "Types.hpp"

namespace datastore
{

class Container
{
public:
   // here in lies my dilemma... how do I store a pointer of data without
   // making this a template class and without using dynamic memory.
   template<typename T>
   Container(const T &value) :
         db_(&Data<T>(value))
   {
   }

   ~Container()
   {
   }

   template<typename T>
   void get(T &value) const
   {
      Data<T> *data = dynamic_cast<Data<T> *>(db_);
      typename Types<T>::value_type tmp(data->value_);
      value = tmp;
   }

   template<typename T>
   void set(const T &value) const
   {
      Data<T> *data = dynamic_cast<Data<T> *>(db_);
      data->value_ = value;
   }

private:
   DataBase *db_;
};

}

#endif /* CONTAINER_HPP_ */
